<title>更改手机号码</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">

<script type="text/javascript" src="#(assets)/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="#(assets)/js/app.js"></script>
<script type="text/javascript" src="#(assets)/js/layer/layer.js"></script>
<style> 
	*{margin:0;padding:0;}
	body{font-family:"Microsoft YaHei",Arial,Helvetica,sans-serif,"宋体";}
	li{list-style-type:none;}
	select,input{-webkit-appearance:none;border:0px;
		-webkit-tap-highlight-color: rgba(0, 0, 0, 0);   
	}
</style>
#@checkToken()
<body bgcolor="#f4f5f9" style="margin:0px;">
<div align=center>
	
	<div id="telephone" align="left" style="background:#fff;height:50px;line-height:50px;width:100%;margin-top:20px;">
		<span style="margin-left:20px;" id="mobile"></span>
	</div>
	<!--验证码-->
	<div id="codes" style="clear:both;background:#fff;height:50px;width:100%;margin-top:10px;"> 
		<div align="center" style="float:left;line-height:50px;font-size:16px;">
			<input placeholder="输入验证码" id="code" style="padding-left:15px;height:50px;width:80%;font-size:16px;border:0px;" type="tel"  />
		</div>
		<input id="getcode" value="获取验证码" style="text-align:center;color:#fa3048;float:right;width:90px;line-height:50px;font-size:14px;margin-right:20px;">
	</div>
	<!--选择问题-->
	<div id="chosequestion" hidden align="left" style="clear:both;background:#fff;height:50px;line-height:50px;width:100%;margin-top:20px;"> 
		<select id="question" style="color:#666;padding-left:20px;height:50px;width:100%;font-size:16px;border:0px;"   />
			  <option value ="">请选择安全问题</option>
			  <option value ="您父亲的生日是几月几日？">问题1：您父亲的生日是几月几日？</option>
			  <option value ="您母亲的生日是几月几日？">问题2：您母亲的生日是几月几日？</option>
			  <option value ="您就读的高中全称叫什么？">问题3：您就读的高中全称叫什么？</option>
			  <option value ="您就职的第一家公司叫什么名称？">问题4：您就职的第一家公司叫什么名称？</option>
			  <option value ="您高中的班主任姓氏是什么？">问题5：您高中的班主任姓氏是什么？</option>
		</select>
	</div> 
	<!--问题答案-->
	<div align="left" hidden id="ansower" style="clear:both;background:#fff;height:50px;line-height:50px;width:100%;margin-top:10px;"> 
		<input placeholder="请填写问题答案" id="answer" style="color:#666;padding-left:20px;height:50px;width:100%;font-size:16px;border:0px;"   />
	</div>
	<div id="usequestion" align="right" style="font-size:14px;clear:both;height:40px;width:100%;line-height:40px;">
		安全问题修改手机号
		<img style="width:14px;margin-right:20px;vertical-align:middle;" src="/assets/images/mobile/personal_jiantou2.png">
	</div>
	<div id="usecode" hidden align="right" style="font-size:14px;clear:both;height:40px;width:100%;line-height:40px;">
		验证码修改手机号
		<img style="width:14px;margin-right:20px;vertical-align:middle;" src="/assets/images/mobile/personal_jiantou2.png">
	</div>
	<div id="next" style="position:fixed;bottom:100px;width:90%;margin-left:5%;color:#fa3048;border:2px solid #fa3048;height:40px;line-height:40px;border-radius:8px;">下一步</div>
	<script> 
	$(document).ready(function(){
		var type = "mobile";
		var url ="#(path)/user/info?token=#(session.token??)";
		$.getJSON(url, function(datainfo) {
			$("#mobile").html(datainfo.data.info.mobile);
			//获取验证码
			$("#getcode").click(function(){
				$.getJSON("#(path)/sys/sendCode?token=#(session.token??)&type=modifyMobileOld&mobile="+datainfo.data.info.mobile, function(datainfo) {
					if(datainfo.code=='success'){
						layer.msg(datainfo.msg,{icon:1,time:1000});
						waittime(getcode);
					}else{
						layer.msg(datainfo.msg,{icon:2,time:1000}); 
					}
				});
			});
			//使用安全问题
			$("#usequestion").click(function(){
				type = "question";
				if(datainfo.data.info.is_set_auth_question==1){
					$("#codes").hide();
					$("#telephone").hide();
					$("#usequestion").hide(); 
					$("#usecode").show();
					$("#chosequestion").show();
					$("#ansower").show();
					$("#code").val("");
				}else{
					layer.msg("您还为设置安全问题！",{icon:2,time:1000},function(){
						window.location.href="/app/page/user-question";
					});
				}
			});
			//使用手机验证码
			$("#usecode").click(function(){
				$("#codes").show();
				$("#telephone").show();
				$("#usequestion").show();
				$("#usecode").hide();
				$("#chosequestion").hide();
				$("#ansower").hide();
				$("#question").val("");
				$("#answer").val("");
				type = "mobile";
			});
		});
		$("#next").click(function(){
			var code = $("#code").val();
			var mobile = $("#mobile").html();
			var question = $("#question").val(); 
			var answer = $("#answer").val(); 
			var code = $("#code").val();  
			$.getJSON("#(path)/user/modifyMobile?token=#(session.token??)&type=check&sms="+code+"&mobile="+mobile+"&question="+question+"&answer="+answer, function(datainfo) {
				if(datainfo.code=='success'){
					layer.msg(datainfo.msg,{icon:1,time:2000},function(){
						window.location.href="#(path)/app/page/user-newmobile?type="+type+"&mobile1="+mobile+"&sms1="+code; 
					});
				}else{
					layer.msg(datainfo.msg,{icon:2,time:1000}); 
				}
			});
		});
		var wait=60;  
		function waittime(o) {  
			if (wait == 0) {  
				o.removeAttribute("disabled");            
				o.value="获取验证码";  
				wait = 60;  
			} else {  
				o.setAttribute("disabled", true);  
				o.value="(" + wait + ")";  
				wait--;  
				setTimeout(function() {  
					waittime(o)  
				},  
				1000)  
			}  
		}  
	});
	</script>
</body>